#include<bits/stdc++.h>
using namespace std;
const double eps=1e-5;
int n,m,V,L;
const int MAXN=1e5+5;
struct node{
    double d,v,a;
}car[MAXN];
struct Info{
    int id;
    int st,ed;
};
vector <Info> v;
int p[MAXN];
bool operator <(const Info &a,const Info &b)
{
    if(a.st!=b.st)
    {
        return a.st<b.st;
    }
    return a.ed<b.ed;
}
void solve()
{
    v.clear();
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++)
    {
        cin>>car[i].d>>car[i].v>>car[i].a;
    }
    for(int i=1;i<=m;i++)
    {
        cin>>p[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(car[i].a==0.0)
        {
            if(car[i].v>1.0*V)
            {
                Info tmp;
                tmp.ed=L;tmp.st=car[i].d;
                tmp.id=i;
                v.push_back(tmp);
            }
            continue;
        }
        else if(car[i].a<0.0)
        {
            if(car[i].v>1.0*V)
            {
                Info tmp;tmp.id=i;
                tmp.st=car[i].d;tmp.ed=min(1.0*L,car[i].d+floor((car[i].v*car[i].v-1.0*V*V)/(2.0*(-car[i].a))-eps));
                v.push_back(tmp);
            }
            continue;
        }
        else if(car[i].a>0.0)
        {
            Info tmp;
            tmp.id=i;
            if(car[i].v>1.0*V)
            {
                tmp.st=car[i].d;
            }
            else
            {
                int st=ceil((1.0*V*V-car[i].v*car[i].v)/(2.0*(car[i].a))+eps)+car[i].d;
                if(st>L)
                {
                    continue;
                }
                tmp.st=st;
            }
            tmp.ed=L;
            v.push_back(tmp);
        }
    }
    sort(v.begin(),v.end());
    int lst=-1;
    int ans1=0,ans2=1;
    int posl=1,posr=m;
    for(int i=0;i<v.size();i++)
    {
        int tposl=lower_bound(p+1,p+m+1,v[i].st)-p;
        if(tposl>m||p[tposl]<v[i].st)
        {
            continue;
        }
        int tposr=upper_bound(p+1,p+m+1,v[i].ed)-p-1;
        if(tposl>tposr)
        {
            continue;
        }
        ans1++;
        if(tposl>posr)
        {
            ans2++;
            posl=tposl,posr=tposr;
            continue;
        }
        posl=max(posl,tposl);
        posr=min(posr,tposr);
    }
    if(ans1==0)
    {
        ans2=0;
    }
    cout<<ans1<<" "<<m-ans2<<"\n";
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
     ios :: sync_with_stdio(0);
     cin.tie(0),cout.tie(0);
    int T;
    cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}